﻿#Include ..\baseHandle.ahk

class OpenConf extends BaseHandle {

  static Handle(parsed) {
    mcf := MeowConf.Of('./cfg/misc/confFile.txt')
    s := mcf.Has(parsed.target), p := Path.Join(A_ScriptDir, './cfg', mcf.Get(parsed.target) '.txt')
    if (parsed.hasParam('v'))
      return this.Done(StrReplace(p, '\', '\\'), s)
    if s and FileExist(p)
      Run(p)
    else return this.Fail(s ? '无文件.' : '未配置.')
    return this.Succ('ok.', 'x')
  }

  static Spec() {
    return {
      cmd: 'oc',
      desc: '打开命令的配置文件',
      format: 'oc [-v] <target>',
      params: [{
        name: 'v',
        desc: '返回值，而不是打开'
      }],
      args: {
        desc: '',
        isOptional: false,
        cacheable: true,
        generator: {
          script: '',
          postProcess: (*) => MeowConf.Of('./cfg/misc/confFile.txt').data.keys
        }
      },
      extra: {
        isEnable: false
      }
    }
  }

}
